<template>
  <div>
    <el-dialog
      :title="title"
      :close-on-click-modal="false"
      v-dialogDrag
      :visible.sync="visible"
    >
      <el-steps :active="active" align-center>
        <el-step title="基本信息"></el-step>
        <el-step title="教育经历/工作经历"></el-step>
        <el-step title="加分项"></el-step>
        <el-step title="地址信息"></el-step>
      </el-steps>
      <el-form
        :model="inputForm"
        style="margin-top: 30px"
        ref="inputForm"
        v-loading="loading"
        :class="method === 'view' ? 'readonly' : ''"
        :disabled="method === 'view'"
        label-width="120px"
      >
        <div v-show="active == 1">
          <el-row :gutter="15">
            <el-col :span="12">
              <el-form-item
                label="投递人手机号"
                prop="deliverer.id"
                :rules="[]"
              >
                <GridSelect
                  title="选择投递人"
                  labelName="phone"
                  labelValue="id"
                  :value="inputForm.deliverer.id"
                  :limit="1"
                  @getValue="
                    (value) => {
                      inputForm.deliverer.id = value;
                    }
                  "
                  :columns="[
                    {
                      prop: 'id',
                      label: '主键',
                    },
                    {
                      prop: 'phone',
                      label: '手机号(账号唯一)',
                    },
                    {
                      prop: 'image',
                      label: '头像',
                    },
                    {
                      prop: 'nikeName',
                      label: '昵称',
                    },
                  ]"
                  :searchs="[
                    {
                      prop: 'phone',
                      label: '手机号(账号唯一)',
                    },
                    {
                      prop: 'nikeName',
                      label: '昵称',
                    },
                  ]"
                  dataListUrl="/userinfo/tUserInfo/list"
                  entityBeanName="tUserInfo"
                  queryEntityUrl="/userinfo/tUserInfo/queryById"
                >
                </GridSelect>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="接收者手机号"
                prop="recipient.id"
                :rules="[]"
              >
                <GridSelect
                  title="选择接收者"
                  labelName="phone"
                  labelValue="id"
                  :value="inputForm.recipient.id"
                  :limit="1"
                  @getValue="
                    (value) => {
                      inputForm.recipient.id = value;
                    }
                  "
                  :columns="[
                    {
                      prop: 'id',
                      label: '主键',
                    },
                    {
                      prop: 'phone',
                      label: '手机号(账号唯一)',
                    },
                    {
                      prop: 'image',
                      label: '头像',
                    },
                    {
                      prop: 'nikeName',
                      label: '昵称',
                    },
                  ]"
                  :searchs="[
                    {
                      prop: 'phone',
                      label: '手机号(账号唯一)',
                    },
                    {
                      prop: 'nikeName',
                      label: '昵称',
                    },
                  ]"
                  dataListUrl="/userinfo/tUserInfo/list"
                  entityBeanName="tUserInfo"
                  queryEntityUrl="/userinfo/tUserInfo/queryById"
                >
                </GridSelect>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="发布人手机号"
                prop="publisher.id"
                :rules="[]"
              >
                <GridSelect
                  title="选择发布人"
                  labelName="phone"
                  labelValue="id"
                  :value="inputForm.publisher.id"
                  :limit="1"
                  @getValue="
                    (value) => {
                      inputForm.publisher.id = value;
                    }
                  "
                  :columns="[
                    {
                      prop: 'id',
                      label: '主键',
                    },
                    {
                      prop: 'phone',
                      label: '手机号(账号唯一)',
                    },
                    {
                      prop: 'image',
                      label: '头像',
                    },
                    {
                      prop: 'nikeName',
                      label: '昵称',
                    },
                  ]"
                  :searchs="[
                    {
                      prop: 'phone',
                      label: '手机号(账号唯一)',
                    },
                    {
                      prop: 'nikeName',
                      label: '昵称',
                    },
                  ]"
                  dataListUrl="/userinfo/tUserInfo/list"
                  entityBeanName="tUserInfo"
                  queryEntityUrl="/userinfo/tUserInfo/queryById"
                >
                </GridSelect>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="简历标题" prop="resumeTitle" :rules="[]">
                <el-input
                  v-model="inputForm.resumeTitle"
                  placeholder="请填写简历标题"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="本人照片" prop="myPhoto" :rules="[]">
                <el-upload
                  ref="myPhoto"
                  v-if="visible"
                  list-type="picture-card"
                  :action="`${this.$http.BASE_URL}/sys/file/webupload/upload?uploadPath=/p_resumedelivery/pResumeDeliveryRecord`"
                  :headers="{ token: $cookie.get('token') }"
                  :on-preview="
                    (file, fileList) => {
                      showImg(inputForm.myPhoto);
                    }
                  "
                  :on-success="
                    (response, file, fileList) => {
                      inputForm.myPhoto = fileList
                        .map(
                          (item) =>
                            (item.response && item.response.url) || item.url
                        )
                        .join('|');
                    }
                  "
                  :on-remove="
                    (file, fileList) => {
                      $http
                        .post(
                          `/sys/file/webupload/deleteByUrl?url=${
                            (file.response && file.response.url) || file.url
                          }`
                        )
                        .then(({ data }) => {
                          $message.success(data.msg);
                        });
                      inputForm.myPhoto = fileList
                        .map((item) => item.url)
                        .join('|');
                    }
                  "
                  :before-remove="
                    (file, fileList) => {
                      return $confirm(`确定移除 ${file.name}？`);
                    }
                  "
                  multiple
                  :limit="1"
                  :on-exceed="
                    (files, fileList) => {
                      $message.warning(
                        `当前限制选择 1 个文件，本次选择了 ${
                          files.length
                        } 个文件，共选择了 ${
                          files.length + fileList.length
                        } 个文件`
                      );
                    }
                  "
                  :file-list="myPhotoArra"
                >
                  <i class="el-icon-plus"></i>
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="真实姓名" prop="realName" :rules="[]">
                <el-input
                  v-model="inputForm.realName"
                  placeholder="请填写真实姓名"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="性别" prop="sexualDistinction" :rules="[]">
                <el-radio-group v-model="inputForm.sexualDistinction">
                  <el-radio label="0">不限</el-radio>
                  <el-radio label="1">男</el-radio>
                  <el-radio label="2">女</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="出生年月" prop="dateBirth" :rules="[]">
                <el-input
                  v-model="inputForm.dateBirth"
                  placeholder="请填写出生年月"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="手机号" prop="cellphoneNumber" :rules="[]">
                <el-input
                  v-model="inputForm.cellphoneNumber"
                  placeholder="请填写手机号"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="参加工作时间" prop="workingTime" :rules="[]">
                <el-input
                  v-model="inputForm.workingTime"
                  placeholder="请填写参加工作时间"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="最高学历"
                prop="highestEducation"
                :rules="[]"
              >
                <el-input
                  v-model="inputForm.highestEducation"
                  placeholder="请填写最高学历"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="意向职位"
                prop="intendedPosition"
                :rules="[]"
              >
                <el-input
                  v-model="inputForm.intendedPosition"
                  placeholder="请填写意向职位"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="期望薪资(元)"
                prop="salaryExpectation"
                :rules="[]"
              >
                <el-input
                  v-model="inputForm.salaryExpectation"
                  placeholder="请填写期望薪资"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item
                label="个人优势"
                prop="personalAdvantages"
                :rules="[]"
              >
                <el-input
                  v-model="inputForm.personalAdvantages"
                  placeholder="请填写个人优势"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="可见范围" prop="visibleRange" :rules="[]">
                <el-radio-group v-model="inputForm.sexualDistinction">
                  <el-radio label="1">全部可见</el-radio>
                  <el-radio label="2">认证企业可见</el-radio>
                  <el-radio label="3">招聘相应职位可见</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="审核状态" prop="auditStatus" :rules="[]">
                <el-radio-group v-model="inputForm.sexualDistinction">
                  <el-radio label="0">待审核</el-radio>
                  <el-radio label="1">已通过</el-radio>
                  <el-radio label="2">已拒绝</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="审核时间" prop="auditTime" :rules="[]">
                <el-date-picker
                  style="width: 100%"
                  v-model="inputForm.auditTime"
                  type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  placeholder="选择日期时间"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="拒绝原因" prop="reasonRejection" :rules="[]">
                <el-input
                  type="textarea"
                  v-model="inputForm.reasonRejection"
                  placeholder="请填写拒绝原因"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="备注信息" prop="remarks" :rules="[]">
                <el-input
                  type="textarea"
                  v-model="inputForm.remarks"
                  placeholder="请填写备注信息"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </div>
        <div v-show="active == 2">
          <el-divider content-position="center"
            ><span style="font-weight: 600">教育经历</span></el-divider
          >
          <div v-for="item in graduationAcademyArray" :key="item">
            <el-card class="box-card">
              <el-col :span="12">
                <el-form-item label="学校" prop="schoolName" :rules="[]">
                  <el-input v-model="item.schoolName" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="在校时间" prop="schoolHours" :rules="[]">
                  <el-input v-model="item.schoolHours" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="主修专业" prop="major" :rules="[]">
                  <el-input v-model="item.major" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item
                  label="在校经历"
                  prop="associationActivity"
                  :rules="[]"
                >
                  <el-input
                    v-model="item.associationActivity"
                    disabled
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-card>
          </div>
          <el-divider content-position="center"
            ><span style="font-weight: 600">工作经历</span></el-divider
          >
          <div v-for="item in workExperienceArray" :key="item">
            <el-card class="box-card">
              <el-col :span="12">
                <el-form-item label="公司名称" prop="corporateName" :rules="[]">
                  <el-input v-model="item.corporateName" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="在职时间" prop="onJobTime" :rules="[]">
                  <el-input v-model="item.onJobTime" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="职业名称" prop="positionName" :rules="[]">
                  <el-input v-model="item.positionName" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="所属行业" prop="industry" :rules="[]">
                  <el-input v-model="item.industry" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="工作内容" prop="jobContent" :rules="[]">
                  <el-input v-model="item.jobContent" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="薪资范围" prop="salaryRange" :rules="[]">
                  <el-input v-model="item.salaryRange" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-card>
          </div>
        </div>
        <div v-show="active == 3">
          <el-divider content-position="center"
            ><span style="font-weight: 600">培训经历</span></el-divider
          >
          <div v-for="item in trainingExperienceArray" :key="item">
            <el-card class="box-card">
              <el-col :span="12">
                <el-form-item label="培训时间" prop="trainingTime" :rules="[]">
                  <el-input v-model="item.trainingTime" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item
                  label="培训机构"
                  prop="trainingInstitutions"
                  :rules="[]"
                >
                  <el-input
                    v-model="item.trainingInstitutions"
                    disabled
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item
                  label="培训课程"
                  prop="trainingCourse"
                  :rules="[]"
                >
                  <el-input v-model="item.trainingCourse" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-card>
          </div>
          <el-divider content-position="center"
            ><span style="font-weight: 600">语言能力</span></el-divider
          >
          <div v-for="item in languageAbilityArray" :key="item">
            <el-card class="box-card">
              <el-col :span="12">
                <el-form-item label="语种" prop="languages" :rules="[]">
                  <el-input v-model="item.languages" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item
                  label="听说能力"
                  prop="listeningSpeakingAbility"
                  :rules="[]"
                >
                  <el-input
                    v-model="item.listeningSpeakingAbility"
                    disabled
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item
                  label="读写能力"
                  prop="readingWritingAbility"
                  :rules="[]"
                >
                  <el-input
                    v-model="item.readingWritingAbility"
                    disabled
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-card>
          </div>
          <el-divider content-position="center"
            ><span style="font-weight: 600">资格证书</span></el-divider
          >
          <div v-for="item in qualificationAarray" :key="item">
            <el-card class="box-card">
              <el-col :span="12">
                <el-form-item
                  label="公司名称"
                  prop="certificateName"
                  :rules="[]"
                >
                  <el-input v-model="item.certificateName" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="获得时间" prop="getTime" :rules="[]">
                  <el-input v-model="item.getTime" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-card>
          </div>
          <el-divider content-position="center"
            ><span style="font-weight: 600">专业技能</span></el-divider
          >
          <div v-for="item in professionalSkillsArray" :key="item">
            <el-card class="box-card">
              <el-col :span="12">
                <el-form-item label="技能名称" prop="skillName" :rules="[]">
                  <el-input v-model="item.skillName" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="使用时长" prop="duration" :rules="[]">
                  <el-input v-model="item.duration" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="掌握程度" prop="mastery" :rules="[]">
                  <el-input v-model="item.mastery" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-card>
          </div>
          <el-divider content-position="center"
            ><span style="font-weight: 600">个人作品</span></el-divider
          >
          <el-card class="box-card">
            <div :span="12" v-for="item in personalWorksArray" :key="item">
              <el-image
                :src="item"
                style="width: 200px; height: 200px"
                :fit="none"
                :preview-src-list="personalWorksArray"
              ></el-image>
            </div>
          </el-card>
        </div>
        <div v-show="active == 4">
          <el-row :gutter="15">
            <el-col :span="12">
              <el-form-item label="家庭地址" prop="homeAddress" :rules="[]">
                <el-input
                  v-model="inputForm.homeAddress"
                  ref="handleinput"
                  id="handleinput"
                  placeholder="请填写家庭地址"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="经度" prop="longitude" :rules="[]">
                <el-input
                  v-model="inputForm.longitude"
                  placeholder="请填写经度"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="纬度" prop="latitude" :rules="[]">
                <el-input
                  v-model="inputForm.latitude"
                  placeholder="请填写纬度"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="地图" prop="">
                <div ref="container" id="containepic"></div>
              </el-form-item>
            </el-col>
          </el-row>
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button v-if="active !== 1" style="margin-top: 12px" @click="upper"
          >上一步</el-button
        >
        <el-button v-if="active !== 4" style="margin-top: 12px" @click="next"
          >下一步</el-button
        >
        <el-button
          v-if="inputForm.auditStatus == '0'"
          style="margin-top: 12px"
          @click="audit(inputForm.id, 1)"
          >通过</el-button
        >
        <el-button
          v-if="inputForm.auditStatus == '0'"
          style="margin-top: 12px"
          @click="refuse(inputForm.id, 2)"
          >拒绝</el-button
        >
        <el-button @click="visible = false">关闭</el-button>
        <el-button
          type="primary"
          v-if="method != 'view'"
          @click="doSubmit()"
          v-noMoreClick
          >确定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import GridSelect from "@/components/gridSelect";
export default {
  data() {
    return {
      title: "",
      method: "",
      visible: false,
      loading: false,
      myPhotoArra: [],
      enclosureWordArra: [],
      enclosurePdfArra: [],
      pictureAttachmentArra: [],
      markersArray: [],
      graduationAcademyArray: [],
      workExperienceArray: [],
      bonusItem: "",
      languageAbilityArray: [],
      qualificationAarray: [],
      professionalSkillsArray: [],
      trainingExperienceArray: [],
      personalWorksArray: [],
      active: 1,
      inputForm: {
        id: "",
        deliverer: {
          id: "",
        },
        recipient: {
          id: "",
        },
        publisher: {
          id: "",
        },
        resumeTitle: "",
        myPhoto: "",
        realName: "",
        sexualDistinction: "",
        dateBirth: "",
        cellphoneNumber: "",
        workingTime: "",
        highestEducation: "",
        graduationAcademy: "",
        workExperience: "",
        homeAddress: "",
        longitude: "",
        latitude: "",
        intendedPosition: "",
        salaryExpectation: "",
        personalAdvantages: "",
        bonusItem: "",
        visibleRange: "",
        auditStatus: "",
        reasonRejection: "",
        auditTime: "",
        enclosureWord: "",
        enclosurePdf: "",
        pictureAttachment: "",
        receivingStatus: "",
        markerBy: {
          id: "",
        },
        remarks: "",
        senderMarkDeleted: "",
        recipientMarkDeleted: "",
      },
    };
  },
  components: {
    GridSelect,
  },
  methods: {
    showImg(imgStrList) {
      var imgList = imgStrList.split("|");
      this.$hevueImgPreview({
        multiple: true,
        nowImgIndex: 0,
        imgList: imgList,
      });
    },
    init(method, id) {
      this.active = "1";
      this.method = method;
      this.inputForm.id = id;
      if (method === "add") {
        this.title = `新建简历投递记录信息`;
      } else if (method === "edit") {
        this.title = "修改简历投递记录信息";
      } else if (method === "view") {
        this.title = "查看简历投递记录信息";
      }
      this.myPhotoArra = [];
      this.enclosureWordArra = [];
      this.enclosurePdfArra = [];
      this.pictureAttachmentArra = [];
      this.visible = true;
      this.loading = false;
      this.$nextTick(() => {
        this.$refs.inputForm.resetFields();
        if (method === "edit" || method === "view") {
          // 修改或者查看
          this.loading = true;
          this.$http({
            url: `/p_resumedelivery/pResumeDeliveryRecord/queryById?id=${this.inputForm.id}`,
            method: "get",
          }).then(({ data }) => {
            this.inputForm = this.recover(
              this.inputForm,
              data.pResumeDeliveryRecord
            );
            this.initMap(this.inputForm.longitude, this.inputForm.latitude);
            this.graduationAcademyArray = JSON.parse(
              this.inputForm.graduationAcademy
            );
            this.workExperienceArray = JSON.parse(
              this.inputForm.workExperience
            );
            this.bonusItem = JSON.parse(this.inputForm.bonusItem);
            console.log(this.bonusItem);
            try {
                this.trainingExperienceArray = JSON.parse(
                    this.bonusItem.trainingExperience
                  );
                console.log("返回的数据是JSON格式的");
              } catch (error) {
                this.trainingExperienceArray = this.bonusItem.trainingExperience;
                console.log("返回的数据不是JSON格式的");
              }
              try {
                this.languageAbilityArray = JSON.parse(
                  this.bonusItem.languageAbility
                );
                console.log("返回的数据是JSON格式的");
              } catch (error) {
                this.languageAbilityArray = this.bonusItem.languageAbility;
                console.log("返回的数据不是JSON格式的");
              }
              try {
                this.qualificationAarray = JSON.parse(
                  this.bonusItem.qualification
                );
                console.log("返回的数据是JSON格式的");
              } catch (error) {
                this.qualificationAarray = this.bonusItem.qualification;
                console.log("返回的数据不是JSON格式的");
              }
              try {
                this.professionalSkillsArray = JSON.parse(
                  this.bonusItem.professionalSkills
                );
                console.log("返回的数据是JSON格式的");
              } catch (error) {
                this.professionalSkillsArray = this.bonusItem.professionalSkills;
                console.log("返回的数据不是JSON格式的");
              }

           
            if (this.bonusItem.personalWorks) {
              this.personalWorksArray = this.bonusItem.personalWorks.split("|");
            }

            this.inputForm.myPhoto.split("|").forEach((item) => {
              if (item.trim().length > 0) {
                this.myPhotoArra.push({
                  name: decodeURIComponent(
                    item.substring(item.lastIndexOf("/") + 1)
                  ),
                  url: item,
                });
              }
            });
            this.inputForm.enclosureWord.split("|").forEach((item) => {
              if (item.trim().length > 0) {
                this.enclosureWordArra.push({
                  name: decodeURIComponent(
                    item.substring(item.lastIndexOf("/") + 1)
                  ),
                  url: item,
                });
              }
            });
            this.inputForm.enclosurePdf.split("|").forEach((item) => {
              if (item.trim().length > 0) {
                this.enclosurePdfArra.push({
                  name: decodeURIComponent(
                    item.substring(item.lastIndexOf("/") + 1)
                  ),
                  url: item,
                });
              }
            });
            this.inputForm.pictureAttachment.split("|").forEach((item) => {
              if (item.trim().length > 0) {
                this.pictureAttachmentArra.push({
                  name: decodeURIComponent(
                    item.substring(item.lastIndexOf("/") + 1)
                  ),
                  url: item,
                });
              }
            });
            this.loading = false;
          });
        } else {
          this.initMap();
        }
      });
    },
    next() {
      this.active++;
    },
    upper() {
      this.active--;
    },
    initMap(longitude, latitude) {
      var that = this;
      let address = "";
      let lat = "36.752508224779746";
      let logt = "119.97121810913086";
      if (!longitude) {
        let lat = latitude;
        let logt = longitude;
      }
      if (this.inputForm.latitude === "") {
        var center = new qq.maps.LatLng(lat, logt);
      } else {
        var center = new qq.maps.LatLng(
          this.inputForm.latitude,
          this.inputForm.longitude
        );
      }
      var map = new qq.maps.Map(document.getElementById("containepic"), {
        center: center,
        zoom: 13,
        disableDefaultUI: true,
      });
      var marker = new qq.maps.Marker({
        position: center,
        map: map,
      });
      that.markersArray.push(marker);
      var infoWin = new qq.maps.InfoWindow({
        map: map,
      }); //此处是点击地图后生成的地标名称
      var geocoder = new qq.maps.Geocoder({
        complete: function (res) {
          that.deleteOverlays();
          map.setCenter(res.detail.location);
          var marker = new qq.maps.Marker({
            map: map,
            position: res.detail.location,
          });
          that.markersArray.push(marker);
        },
      });

      qq.maps.event.addListener(map, "click", function (event) {
        that.deleteOverlays();
        // this.latitude = event.latLng.getLat();
        // this.longiistude = event.latLng.getLng();
        // console.log(this.longiistude, this.latitude);
        that.inputForm.longitude = event.latLng.getLng();
        that.inputForm.latitude = event.latLng.getLat();
        var position = new qq.maps.LatLng(
          that.inputForm.latitude,
          that.inputForm.longitude
        );
        var marker = new qq.maps.Marker({
          map: map,
          position: position,
        });
        that.markersArray.push(marker);
      });
      document
        .getElementById("handleinput")
        .addEventListener("blur", function () {
          geocoder.getLocation(that.inputForm.homeAddress);
        });
    },
    deleteOverlays() {
      if (this.markersArray) {
        for (var i in this.markersArray) {
          this.markersArray[i].setMap(null);
        }
        this.markersArray.length = 0;
      }
    },
    audit(id, status) {
      this.$confirm(`确定当前操作?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        this.loading = true;
        this.$http({
          url: "/p_resumedelivery/pResumeDeliveryRecord/audit",
          method: "post",
          params: { id: id, auditStatus: status },
        }).then(({ data }) => {
          if (data && data.success) {
            this.visible = false;
            this.$message.success(data.msg);
            this.$emit("refreshDataList");
          }
          if (!data.success) {
            this.visible = false;
            this.$message.success(data.msg);
            this.$emit("refreshDataList");
          }
          this.loading = false;
        });
      });
    },
    //拒绝审核
    refuse(id, status) {
      this.$prompt("请输入拒绝原因", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
      })
        .then(({ value }) => {
          if (!value) {
            this.$message.error("请输入拒绝原因");
            return false;
          }
          this.loading = true;
          this.$http({
            url: "/p_resumedelivery/pResumeDeliveryRecord/audit",
            method: "post",
            params: { id: id, auditStatus: status, refuseReason: value },
          }).then(({ data }) => {
            if (data && data.success) {
              this.visible = false;
              this.$message.success(data.msg);
              this.$emit("refreshDataList");
            }
            if (!data.success) {
              this.visible = false;
              this.$message.success(data.msg);
              this.$emit("refreshDataList");
            }
            this.loading = false;
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消输入",
          });
        });
    },
    // 表单提交
    doSubmit() {
      this.$refs["inputForm"].validate((valid) => {
        if (valid) {
          this.loading = true;
          this.$http({
            url: `/p_resumedelivery/pResumeDeliveryRecord/save`,
            method: "post",
            data: this.inputForm,
          }).then(({ data }) => {
            this.loading = false;
            if (data && data.success) {
              this.visible = false;
              this.$message.success(data.msg);
              this.$emit("refreshDataList");
            }
          });
        }
      });
    },
  },
};
</script>
